<template>
  <div>
    <div>
      <div class="login-div">
        <img
          class="login"
          src="https://img.miyabaobei.com/d1/p6/2020/06/19/7c/3b/7c3b898b95f78a0581ec8967bee59088342465557.png"
          alt
        />
      </div>
      <div class="content">
        <div class="temp">
          <van-field
            v-model="form.loginName"
            class="van-tmp"
            label="+86 &gt;"
            placeholder="请输入手机号码"
          />
        </div>
        <!-- <div class="temp">
          <van-field v-model="form.sms" center clearable placeholder="请输入短信验证码">
            <template #button v-if="Mobilephone">
              <van-button size="small" plain class="btn" type="default">发送验证码</van-button>
            </template>
            <template #button v-else>
              <van-button size="small" plain class="btn" type="primary">发送验证码</van-button>
            </template>
          </van-field>
        </div>-->
        <div class="top">
          <van-button v-if="Mobilephone" type="primary" class="btn red" @click="login" block>登录or注册</van-button>
          <van-button v-else type="default" class="btn col" block>登录or注册</van-button>
        </div>
        <div class="martop">
          <span class="size">用户注册即代表同意</span>
          <span>
            <a href="#" class="font size left">蜜芽服务条款</a>
          </span>
        </div>
        <!-- <div class="mtop">
          <span>其他登录方式</span>
          <div class="fle">
            <div>
              <van-image class="img" src="https://m.mia.com/resources/img/weixin.png" />
            </div>
            <div>
              <van-image class="img" src="https://m.mia.com/resources/img/weibo.png" />
            </div>
          </div>
        </div>-->
      </div>
    </div>
    <yzm @sure="text" v-if="show"></yzm>
  </div>
</template>

<script>
//  (/^1[3456789]\d{9}$/.test(form.value))
import { mapActions } from "vuex";
export default {
  name: "login",
  layout: true,
  data() {
    return {
      form: {
        loginName: 13753938781,
      },
      show: false,
    };
  },
  methods: {
    ...mapActions("login", ["Applogin"]),
    async login() {
      this.show = true;
    },
    //滑块
    async text(e) {
      if (e) {
        let from = { ...this.form };
        from.name = "miya" + this.form.loginName;
        let r = await this.Applogin(from);
        this.form = {};
        if (r) {
          this.$router.push("/setting");
        }
        this.show = false;
        console.log("验证成功");
      } else {
        console.log("验证失败");
      }
    },
  },
  computed: {
    Mobilephone() {
      return /^1[3456789]\d{9}$/.test(this.form.loginName);
    },
  },
};
</script>

<style  scoped>
.login-div {
  text-align: center;
  padding-top: 0.34rem;
}

.login {
  width: 0.81rem;
}

.content {
  width: 80%;
  margin: 0 auto;
}

.temp {
  border-bottom: 1px solid #ccc;
}

.van-field__label {
  -webkit-box-flex: 0;
  -webkit-flex: none;
  flex: none;
  box-sizing: border-box;
  width: 6.2em;
  margin-right: -35px;
  color: #646566;
  text-align: left;
  word-wrap: break-word;
}

.btn {
  border-radius: 20px;
  /* counter-reset: white; */
}

.top {
  margin-top: 40px;
  border-radius: 20px;
}

.col {
  background-color: #ccc;
}

.red {
  background-color: red;
}

.font {
  color: red;
}

.size {
  font-size: 12px;
}

.left {
  margin-left: 10px;
  text-decoration: underline;
}

.martop {
  margin-top: 10px;
}

.mtop {
  text-align: center;
  margin: 150px 0 auto;
  font-size: 13px;
}

.fle {
  display: flex;
  justify-content: space-around;
  margin-top: 20px;
}

.img {
  width: 0.76rem;
  height: 0.76rem;
}
</style>